﻿<?php
class GlobalAction extends Action
{
	
	public function _initialize(){ 
	header("Content-type: text/html; charset=utf-8");
	} 
   
//操作v信息提示 $type : success,error errorurl
protected function _message($type = 'success',$content = '更新成功',$jumpUrl = __URL__,$time = 1,$ajax = false){
	$jumpUrl = empty($jumpUrl) ?__URL__ : $jumpUrl ;
	switch ($type){
		case 'success':
			$this->assign('jumpUrl',$jumpUrl);
			$this->assign('waitSecond',$time);
			$this->success($content,$ajax);
			break;
		case 'error':
			$this->assign('jumpUrl','javascript:history.back(-1);');
			$this->assign('waitSecond',$time);
			$this->assign('error',$content);
			$this->error($content,$ajax);
			break;
		case 'errorUrl':
			$this->assign('jumpUrl',$jumpUrl);
			$this->assign('waitSecond',$time);
			$this->assign('error',$content);
			$this->error($content,$ajax);
			break;
		default:
			die('error type');
			break;
	}
}

//获取指定表中符合条件的一条记录的字段
protected function _get_field($table,$condition,$field)
{
	$list_temp = M($table)->where($condition)->getField($field);
	//dump($list_temp);
	return $list_temp;	
}
//推荐公司
protected function rec_company($num=10)
{
	$list = M('company')->where('w_tuijian=1')->limit($num)->order('id desc')->select();
	foreach($list as $k=>$v)
	{
		
		$list[$k]['product_num'] = M('products')->where('company_id='.$v['id'])->count();
	}
	return $list;
}
//推荐平台帮助
protected function rec_help($num=8){
	$list = M('sys_help')->limit($num)->order('w_index desc,id desc')->select();
	return $list;	
	}
//推荐博客人物
protected function rec_person($num=6){
	$list = M('company_user')->limit($num)->where('show_index=1 ')->order('user_id desc')->select();
	foreach($list as $k=>$v){
	if($v['head_pic'] == ''){
		if(mb_strpos($v['sex'],'男') === false)
		{
			$list[$k]['head_pic'] = '__PUBLIC__/images/3006.gif';
		}
		else
		{
			$list[$k]['head_pic'] = '__PUBLIC__/images/3003.gif';
		}
	}
		}
	return $list;	
}
//招聘
protected function new_zhaopin($num=8){
	$list = M('company_zhaopin')->limit($num)->order('zhaopin_id desc')->select();
	return $list;	
}


	

}
?>